$(function() {
    var f = $("#hidGoodsID").val();
    var p = $("#hidCodeID").val();
    var m = $("#hidShowTime").val() == "1";
    if (m) {
    } else {
        var d = function(q) {
            $.PageDialog.fail(q);
        };
        var h = function(q) {
            $.PageDialog.ok("<s></s>" + q);
        };
        var l = function(r) {
          var goods_id = localData.get('goods_id');
          var price = $('#goprice').val();
          if(!goods_id) {
              d('商品不存在');
              appClose('item',api);
              return;
          }
            if(r==1){
                h('添加成功');
                addCart(goods_id,price,1,'item');
                var jsfun = 'funcGoto();';
                api.execScript({
                    name: 'root',
                    script: jsfun
                });
                api.closeFrame({
                    name: 'cate'
                });
				appClose('payment',api);
                appClose('orderlist',api);
				appClose('userindex',api);
				appClose('fansrecord',api);
				appClose('fansrecords',api);
				appClose('fansmanage',api);
                appClose('userbuylist',api);
                appClose('userbuydetail',api);
                appClose('cate_goods',api);
				
				appClose('groupdb',api);
				appClose('team_cartlist',api);
				appClose('userteambuylist',api);
				appClose('teambuyrecord',api);
				appClose('teamorderlist',api);
				appClose('js_result',api);
				appClose('userbuydetail',api);
				appClose('utbuydetail',api);
				appClose('createbuydetail',api);
				
                appClose('search',api);
				appClose('myfans',api);
				appClose('commissions',api);
				appClose('basedata',api);
                appClose('dataserver',api);
                appClose('item',api);
            }else if(r == 0){
                h('加入购物车成功');
                addCart(goods_id,price,1,'item');
            }
        };
        var i = function() {
            var q = $("#btnBuyBox");
            q.children("a").eq(0).click(function() {
                l(1);
            });
            q.children("a").eq(1).click(function() {
                l(0);
            });
        };
        i();
        var c = function(q) {
            if (q && q.stopPropagation) {
                q.stopPropagation();
            } else {
                window.event.cancelBubble = true;
            }
        };
        var b = $("#prevPeriod");
    }
});